package com.cloud.class04.apis;

import com.cloud.class04.entities.PayDTO;
import com.cloud.class04.resp.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

//FeignClient注解的value属性值是服务提供者的服务名
@FeignClient(value = "cloud-payment-service")
public interface PayFeignApi {


    @PostMapping(value = "/pay/add")
    public ResultData addPay(@RequestBody PayDTO pay);

    @DeleteMapping(value = "/pay/del/{id}")
    public ResultData deletePay(@PathVariable("id") Integer id);

    @PutMapping(value = "/pay/update")
    public ResultData updatePay(@RequestBody PayDTO payDTO);

    @GetMapping(value = "/pay/get/{id}")
    public ResultData getById(@PathVariable("id") Integer id);


    //全部查询getall作为家庭作业
    @GetMapping(value = "/pay/getall")
    public ResultData getAll();


    @GetMapping(value = "/pay/get/info")
    public String getInfoByConsul();
//    Resilience4J CircuitBreaker的例子

    @GetMapping("/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id);

    /**
     * Resilience4j Bulkhead 的例子
     *
     * @param id
     * @return
     */
    @GetMapping("/pay/bulkhead/{id}")
    public String myBulkHead(@PathVariable("id") Integer id);
//    java8新特性
//    public default String test() {
//        return "test";
//    }
//    public static String test2() {
//        return "test2";
//    }
//
//    public static void main(String[] args) {
//        System.out.println(test2());
////        test();
////        this.test();
//    }


    /**
     * Resilience4j Ratelimit 的例子
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/ratelimit/{id}")
    public String myRatelimit(@PathVariable("id") Integer id);

    /**
     * Micrometer(Sleuth)进行链路监控的例子
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/pay/micrometer/{id}")
    public String myMicrometer(@PathVariable("id") Integer id);


}
